/**
 * 记录话务数据
 * @author         xianggui lei
 * @date           2019-07-15 11:57
 * @version        1.0.0
 */
/*
 * 插入新的会话流水
 */
function insertHistory(data) {
    let incomingCause = "";
    switch (data['sessionType']) {
        case 'n':
            incomingCause = 'new';
            break;
        case 't':
            incomingCause = 'transfer';
            break;
        case 'c':
            incomingCause = 'conference';
            break
        default:
            incomingCause = 'other';
    }
    parent.$.post("saveSessionHistory",
        {
            id: data['id'],
            custChannel: data['channelType'],
            callId: data['contactId'],
            direct: data['direct'],
            caller: data['caller'],
            callee: data['callee'],
            isConnected: data['isconnected'],
            incomingCause: incomingCause,
            sessionId: data['sessionId'],
            custRes: 'ivr',//预留
            custGroup: 'ivr',//预留
            custName: data['consumerName'],
            custNo: data['consumerId'],
            isAllot: '1',
            extNo:data['extNo'],
        },
        function () {
            console.info('插入会话' + data['sessionId'] + '成功');
        },"json"
    );
}
/*
 * @param type 操作类型 'answer','transfer','hangup','acw'
 * @param id 会话id
 * @param releaseCause 挂机原因
 */
function updateHistory(type, id, custName, custNo, releaseCause) {
    parent.$.post("updateSessionHistory",
        {
            sessionId: id,
            releaseCause: releaseCause,
            actionType: type,
            custName: custName,
            custNo: custNo
        },
        function () {
            console.info('修改会话' + data['sessionId'] + '成功');
        },"json"
    );
}